import { ref, onMounted } from "vue";
import { useDetail, useList } from "@/hooks";
import { getTimeRules } from "@/command/apiTool";
import { getAction, postAction } from "@/command/netTool";
import * as vant from "vant";
const { showFailToast, showSuccessToast } = vant;
import { useRouter } from "vue-router";
import moment from "moment";
export const useRequest = () => {
  const router = useRouter();
  const confirm = (params: any) => {
    if (getTimeRules(params.startDate, params.endDate)) {
      showFailToast("营业结束时间不能早于开始时间");
      return;
    }
    postAction(
      "/api/h5/richInspection/lager/saveInspectionDto",
      { ...params },
      { isResolve: true }
    ).then((e) => {
      showSuccessToast("提交成功");
      router.back();
    });
  };
  const [productList] = useDetail("/api/H5/util/getProductLevel", [], {
    callBack: (data: any[]) => {
      return data.filter((e) => e.value != "-1");
    },
  });
  const [detail] = useDetail("/api/h5/richInspection/lager/getDetail", {
    entityLogo: "",
    list: [],
  });
  return {
    productList,
    detail,
    confirm,
  };
};
